import type { CartResult } from '@/types/cart'
import { http } from '@/utils/http'
export const useCartApi = () => {
    return {
        addCart: (data: { skuId: string, count: number }) => {
            return http({
                method: 'POST',
                url: '/member/cart',
                data
            })
        },
        getCart: () => {
            return http<CartResult[]>({
                method: 'GET',
                url: '/member/cart'
            })
        },
        deleteCart: (data: { ids: string[] }) => {
            return http({
                method: 'DELETE',
                url: '/member/cart',
                data
            })
        },
        upDateCartBySkuId: (id:string,data: {selected?:boolean,count?:number}) => {
            return http<CartResult>({
                method: 'PUT',
                url: `/member/cart/${id}`,
                data
            })
        },
        upDateAllSelected: (data: {selected?:boolean}) => {
            return http<CartResult>({
                method: 'PUT',
                url: `/member/cart/selected`,
                data
            })
        }
    }
} 